<template>
	<el-dialog
		:visible.sync="auditTaskShow"
		@close="closeSelf"
		width="50%"
		:show-close='false'
		:append-to-body='true'
		class = "qianfaDialog"
		>
		<span slot="title" class="dialog-title">
		  	签发
			<el-button  size="mini" @click="closeSelf" class="popupClose">关闭</el-button>
		</span>
		<el-row style = "margin-bottom:20px;">
			<span>是否通过：</span>
			 <el-select v-model="selectValue" placeholder="请选择" size="mini">
			    <el-option label="同意" :value="true"></el-option>
			    <el-option label="驳回" :value="false"></el-option>
			  </el-select>
		</el-row>
		<el-row v-if="!selectValue">
			<div style="padding:10px 0;" class = "inlineblock">驳回意见：</div>
			<el-input
			  type="textarea"
			  :rows="2"
			  size="mini"
			  placeholder="请输入内容"
			  v-model="remark" class = "inlineblock" style = "width:calc(100% - 80px)">
			</el-input>
		</el-row>
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="closeSelf" size="mini">取 消</el-button>
		    <el-button type="primary" @click="submitClick" size="mini" :disabled="!isRepeat">确 定</el-button>
		  </span>
	</el-dialog>
</template>

<script>
	export default{
		props:['auditTaskDialogShow','getPlanData'],
		data(){
			return {
				selectValue:true,
				remark:	'',
        isRepeat: true,
			}
		},
		methods:{
			closeSelf(){
				this.$emit('update:auditTaskDialogShow', false);
				this.isPass = true;
			},
			submitClick(){
				let params,msg;
				if(this.selectValue){
						 params = {id:this.getPlanData.id,result:this.selectValue}
						 msg = '签发成功！'
				}else{
          if(this.remark == null || this.remark == undefined || this.remark == ""){
            this.$notify({
            	 showClose: true,
            	message: '请输入驳回意见!',
            	type: 'warning',
            	title:"成功"
            })
            return;
          }
					 params = {id:this.getPlanData.id,result:this.selectValue,remark:this.remark}
					 msg = '驳回成功！'

				}
        this.isRepeat = false
 				this.$http({
			          method: 'post',
			          apiUrl: '/detection/auditTask.htm',
			          params:params,
			          isJson:false,
			       }).then(res=>{
               this.isRepeat = true;
			          if(res.code === 0){

			          	// this.$notify({
						// 	showClose: true,
						// 	message: msg,
						// 	type: 'success',
						// 	title:"成功"
						// })
						if(this.selectValue){
							this.finshTask(this.getPlanData);
						}
			          	this.$parent.closeTask()
							this.$store.dispatch('getWorkflowList',0).then(res=>{
							this.$notify({
								 showClose: true,
								message: '操作成功',
								type: 'success',
								title:"成功"
							})
						})
			          }else{
//			          	reject(err)
			          }
			        },)
			       this.$emit('update:auditTaskDialogShow',false)
			},
			finshTask(data){
				this.$http({
			          method: 'post',
			          apiUrl: '/detection/finishTask.htm',
			          params:data,
			          isJson:true,
			       }).then(res=>{
						if(res.code){
							this.$parent.$parent.getPlanList(this.$parent.$parent.planQuery)
						}
				   })
			}
		},
		computed:{
			auditTaskShow:{
				get(){
					return this.auditTaskDialogShow
				},
				set(){

				}
			}
		}
	}
</script>

<style>
	.qianfaDialog .el-dialog {
		height: 50%;
	}
	.qianfaDialog .el-dialog .el-dialog__body{
		padding:18px;
	}
</style>
